<!-- 查看下级 -->
<template>
  <div>
    <el-dialog title="查看下级" :visible.sync="memberList.showModal" width="80%" top="5vh">
      <el-form :inline="true" class="demo-form-inline" style="padding-left:20px!important;">
        <!-- <el-form-item>
          <el-input v-model="data.userName" size="medium" class="iup_width200" placeholder="请输入用户名称"></el-input>
        </el-form-item> -->
        <el-form-item>
          <el-input v-model="data.mobile" size="medium" class="iup_width200" placeholder="请输入手机号"></el-input>
        </el-form-item>
        <!-- <el-form-item>
          <el-input v-model="data.idcard" size="medium" class="iup_width200"  placeholder="请输入身份证"></el-input>
        </el-form-item> -->
        <el-form-item>
          <el-select v-model="data.level" size="medium" class="iup_width200" placeholder="请选择会员等级">
            <el-option v-for="item in levelList" :key="item.code" :label="item.name" :value="item.code"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" size="medium" @click="searchList">查询</el-button>
          <el-button type="primary" size="medium" @click="resetList">重置</el-button>
          <!-- <el-button type="primary" size="medium">添加会员</el-button> -->
        </el-form-item>
      </el-form>
      <el-table :data="getList" v-loading="loading" max-height="400" element-loading-text="数据加载中" empty-text border stripe>
        <div slot="empty">
          <div v-if="loading"></div>
          <div v-else>暂无数据</div>
        </div>
        <el-table-column type="index" label="序号" align="center" width="70"></el-table-column>
        <!-- <el-table-column prop="userName" label="用户名称" align="center"></el-table-column> -->
        <el-table-column prop="mobile" label="手机号" align="center"></el-table-column>
        <!-- <el-table-column prop="name" label="真实姓名" align="center"></el-table-column> -->
        <!-- <el-table-column prop="idcard" label="身份证" align="center" width="180"></el-table-column> -->
        <el-table-column prop="levelName" label="会员等级" align="center" width="120"></el-table-column>
        <el-table-column prop="freezeBalanceAmt" label="冻结余额" align="center" width="120">
          <template slot-scope="scope">
            <span class="green">{{common.formatAmount(scope.row.freezeBalanceAmt,2)}}</span>
          </template>
        </el-table-column>
        <el-table-column prop="cashedAmt" label="已提现金额" align="center" width="120">
          <template slot-scope="scope">
            <span class="green">{{common.formatAmount(scope.row.cashedAmt,2)}}</span>
          </template>
        </el-table-column>
        <el-table-column prop="balanceAmt" label="余额" align="center" width="120">
          <template slot-scope="scope">
            <span class="green">{{common.formatAmount(scope.row.balanceAmt,2)}}</span>
          </template>
        </el-table-column>
        <el-table-column prop="addTime" label="注册时间" :formatter="common.formatTime" align="center"></el-table-column>
        <el-table-column prop="shareName" label="上级名称" align="center"></el-table-column>
        <el-table-column prop="teamCount" label="团队数量" align="center"></el-table-column>
        <el-table-column prop="subCount" label="下级数量" align="center"></el-table-column>
      </el-table>
      <!-- 分页开始 -->
      <pagination :total="total" :pageData="data" @hanleSize="changePage" @hanlePage="handleSizeChange"></pagination>
      <!-- 底部按钮开始 -->
      <span slot="footer" class="dialog-footer">
        <el-button size="medium" @click="memberList.showModal = false">关闭</el-button>
      </span>
      <!-- 底部按钮结束 -->
    </el-dialog>
  </div>
</template>
<script>
export default {
  props: ['memberList'],
  data () {
    return {
      data: {
        pageSize: 10,
        currentPage: 1,
        userName: "",
        mobile: "",
        idcard: "",
        level: "",
        shareId: '',
      },
      getList: [],
      total: 0,
      loading: false,
      levelList: [],
    }
  },
  methods: {
    // 获取字典表
    async getterm () {
      this.levelList = await this.common.enumsList('USER_LEVEL')
    },
    //点击页数触发
    changePage (page) {
      this.data.currentPage = page;
      this.getMemberDetail();
    },
    //选择页数最多显示几条数据
    handleSizeChange (val) {
      this.data.pageSize = val;
      this.getMemberDetail();
    },
    //查询关键字
    searchList () {
      this.data.currentPage = 1;
      this.getMemberDetail();
    },
    //重置列表
    resetList () {
      Object.assign(this.$data.data, this.$options.data().data); //重置列表
      this.getMemberDetail();
    },
    async getMemberDetail () {
      this.data.shareId = this.memberList.id
      const url = `/member/queryPage`
      const result = await this.request.httpRequest('POST', url, this.data)
      if (result.code == 200) {
        this.total = result.data.totalRows;
        this.data.pageSize = result.data.pageSize;
        this.data.currentPage = result.data.currentPage;
        this.getList = result.data.datas;
      } else {
        this.$message({ type: "error", message: result.msg });
      }
    }
  },
  mounted () {
    this.getterm();
    this.getMemberDetail();
  },
}
</script>
<style scoped>
.el-form {
  padding: 15px 0px !important;
}
.el-form-item {
  margin-bottom: 0px !important;
}
</style>